<template>
    <div class="qingwu">
        <div class="admin_table_page_title">
            <a-button @click="$router.back()" class="float_right" icon="arrow-left">返回</a-button>
            商品详情
        </div>
        <div class="unline underm"></div>
        <div class="admin_form">
            <a-form-model :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
                <a-form-model-item label="名称">{{info.goods_name}}</a-form-model-item>
                <a-form-model-item label="描述">{{info.goods_content||'-'}}</a-form-model-item>
                <a-form-model-item label="商品分类">{{info.cate_name||'-'}}</a-form-model-item>
                <a-form-model-item label="价格">￥{{info.goods_price}}</a-form-model-item>
                <a-form-model-item label="商品图片">
                    <div class="goods_image">
                        <div class="item" v-if="info.goods_images.length > 0">
                            <div class="item_img" v-for="(v,k) in info.goods_images" :key="k">
                                <img :src="v" alt=""/>
                            </div>
                            <div class="clear"></div>
                        </div>
                        <div class="item noimg" v-else>
                            <a-font type="iconphoto"/>
                        </div>
                    </div>
                </a-form-model-item>

                <a-form-model-item label="状态">{{info.sale_text}}</a-form-model-item>

                <a-form-model-item label="删除原因" v-if="info.is_sale == 3 || info.is_sale == 4">
                    <a-textarea v-model="info.refuse_info"/>
                </a-form-model-item>

            </a-form-model>


        </div>
    </div>
</template>

<script>
    export default {
        components: {},
        props: {},
        data() {
            return {
                info: {
                    goods_images: [],
                },
                id: 0,
            };
        },
        watch: {},
        computed: {},
        methods: {
            handleSubmit(e) {
                let params = {
                    refuse_info: e ? '' : this.info.refuse_info,
                }
                this.$put(this.$api.fleaGoods + '/' + this.info.id, params).then(res => {
                    if (res.code == 200) {
                        this.$message.success(res.msg)
                        return this.$router.back();
                    } else {
                        return this.$message.error(res.msg)
                    }
                })


            },
            get_info() {
                this.$get(this.$api.fleaGoods + '/' + this.id).then(res => {
                    this.info = res.data;
                    console.log(this.info.goods_images)
                    this.$forceUpdate();
                })
            },

            onload() {

                // 判断你是否是编辑
                if (!this.$isEmpty(this.$route.params.id)) {
                    this.id = this.$route.params.id;
                    this.get_info();
                }
            },
            // 编辑器切换平台
            check_platform(status) {
                this.platform = status;
            },


        },
        created() {
            this.onload();
        },
        mounted() {
        }
    };
</script>
<style lang="scss" scoped>
    .goods_content {
        border: 1px solid #efefef;
        padding: 20px;
        margin-top: 20px;
        margin-bottom: 15px;
    }

    .admin_editor_span {
        margin-right: 10px;
        border: 1px solid #efefef;
        line-height: 30px;
        padding: 4px 10px;
        border-radius: 3px;
        margin-bottom: 10px;
        cursor: pointer;

        &:hover {
            border-color: #ccc;
        }

        &.check {
            border-color: #ccc;
        }
    }

    .goods_upload_btn {
        margin-top: 10px;
    }

    .goods_specs {
        border: 1px solid #efefef;
        margin-top: 10px;
    }

    .row_td {
        padding: 8px;
    }

    .goods_image {
        .item {
            &.noimg {
                width: 160px;
                height: 160px;
                background: #efefef;
                text-align: center;
                border-radius: 4px;

                i {
                    font-size: 40px;
                    line-height: 160px;
                    color: #999;
                }
            }

            .item_img {
                width: 160px;
                height: 160px;
                display: block;
                float: left;
                box-sizing: border-box;
                margin-right: 10px;
                margin-bottom: 10px;
                position: relative;
                border: 1px solid #efefef;

                img {
                    width: 100%;
                    height: 100%;
                    border-radius: 4px;
                }

                .item_master {
                    position: absolute;
                    left: 0;
                    bottom: 0;
                    border-radius: 0 0 4px 4px;
                    background: #000;
                    line-height: 26px;
                    height: 26px;
                    width: 100%;
                    z-index: 3;
                    background: rgba(0, 0, 0, 0.5);
                    color: #fff;
                    text-align: center;
                    font-size: 12px;
                }

                &:hover .item_bg {
                    display: block;
                }
            }
        }
    }

    .row_th {
        background: #efefef;
    }

    .col_th {
        text-align: center;
    }
</style>
